<template>
	<view>
		<page-head headTitle="消息中心" rightWords="全部已读" :returnButton="true" @clickLeftReturn="clickLeftReturn" @clickRight="clickRight"></page-head>
		<view class="m-t9 bg-white">
			<navigator :url="'../../chatDetails/chatDetails?ssid='+item.ssid" v-for="(item,index) in list">
				<view class="p-l-r3 p-t-b3 flex justify-between border-botton">
					<view class="flex align-center min-width">
						<view class="position-r">
							<image :src="item.avatar" class="border-r1 my-image mr"></image>
							<text class="badge" v-show="item.news">{{item.news}}</text>
						</view>
						<view class="flex-1 overflow">
							<view class="flex justify-between"><text class="fs-32">{{item.name}}</text><text class="input-goods">{{item.last_time}}</text></view>
							<view class="flex white-space input-goods">{{item.last_msg}}</view>
						</view>
					</view>
				</view>
			</navigator>
		</view>
	</view>
</template>

<script>
import pageHead from '@/components/common/page-head.vue'
	export default {
		components:{
			pageHead
		},
		data() {
			return {
				list:[],
			}
		},
		onLoad() {
			this.getList();
		},
		methods: {
			clickLeftReturn(){
				const pages = getCurrentPages() ;
				if(pages.length >1) {
					uni.navigateBack({
						delta: 1
					});
				}else{
					//返回上一页失败后强制回到首页
					uni.redirectTo({
						url: '../index/index'
					})
				}
			},
			clickRight(){
				
			},
			getList(){
				this.$myRequest({
					method:'POST',
					url:'/api/guide/messages',
				}).then(res=>{
					if(res.data.code == 1){
						this.list = res.data.data.list;
					}
				})
			}
		}
	}
</script>

<style scoped>
.my-image{width: 100rpx;height: 100rpx;}
.badge{position: absolute;right: 22rpx;top: -6rpx;color: #FFFFFF; border-radius: 100%; background-color: #FF4141;padding:2rpx 12rpx;line-height: 1.3;}
</style>
